package br.com.ffm.mtfw.classes;

import br.com.ffm.mtfw.enums.OperationType;

/**
 * Class that associates a OperationType to a TenantColumn
 *
 * @author matheus
 */
public class SelectOperation {

    private TenantColumn tenantColumn;
    private OperationType operationType;

    public SelectOperation(OperationType operationType, TenantColumn tenantColumn) {
        this.operationType = operationType;
        this.tenantColumn = tenantColumn;
    }

    public SelectOperation(OperationType operationType) {
        this.operationType = operationType;
    }

    public TenantColumn getTenantColumn() {
        return tenantColumn;
    }

    public boolean isTenantColumnNull() {
        return tenantColumn == null;
    }

    public boolean isCountOperation() {
        return !this.isNullOperationType() && this.operationType.equals(OperationType.COUNT);
    }

    public boolean isSumOperation() {
        return !this.isNullOperationType() && this.operationType.equals(OperationType.SUM);
    }

    public boolean isAvgOperation() {
        return !this.isNullOperationType() && this.operationType.equals(OperationType.AVG);
    }

    public boolean isMaxOperation() {
        return !this.isNullOperationType() && this.operationType.equals(OperationType.MAX);
    }

    public boolean isMinOperation() {
        return !this.isNullOperationType() && this.operationType.equals(OperationType.MIN);
    }

    public boolean isNullOperationType() {
        return this.operationType == null;
    }
}
